

package com.maoshi.shop.multishop.controller;

import cn.hutool.core.util.StrUtil;
import com.maoshi.shop.bean.model.ShopWalletLog;
import com.maoshi.shop.security.multishop.util.SecurityUtils;
import com.maoshi.shop.service.ShopWalletLogService;
import com.maoshi.shop.common.annotation.SysLog;

import javax.validation.Valid;

import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import lombok.AllArgsConstructor;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.maoshi.shop.common.util.PageParam;
import com.baomidou.mybatisplus.core.metadata.IPage;


/**
 * 商家钱包记录
 *
 * @author Dwl
 * @date 2019-09-19 14:02:57
 */
@RestController
@AllArgsConstructor
@RequestMapping("/shop/shopWalletLog" )
public class ShopWalletLogController {

    private final ShopWalletLogService shopWalletLogService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param shopWalletLog 商家钱包记录
     * @return 分页数据
     */
    @GetMapping("/page" )
    public ResponseEntity<IPage<ShopWalletLog>> getShopWalletLogPage(PageParam<ShopWalletLog> page, ShopWalletLog shopWalletLog) {
        return ResponseEntity.ok(shopWalletLogService.page(page, new LambdaQueryWrapper<ShopWalletLog>()
                .eq(StrUtil.isNotBlank(shopWalletLog.getOrderNumber()), ShopWalletLog::getOrderNumber, shopWalletLog.getOrderNumber())
                .eq(shopWalletLog.getAmountType() != null, ShopWalletLog::getAmountType, shopWalletLog.getAmountType())
                .eq(shopWalletLog.getIoType() != null, ShopWalletLog::getIoType, shopWalletLog.getIoType())
                .eq(shopWalletLog.getReason() != null, ShopWalletLog::getReason,shopWalletLog.getReason())
                .eq(ShopWalletLog::getShopId, SecurityUtils.getShopUser().getShopId()).orderByDesc(ShopWalletLog::getWalletLogId)));
    }

}
